<template>
	<view class="notice-detail" v-if="detail">
		<g-navbar title="公告详情" />
		<view class="notice-detail-main">
			<view class="notice-title">
				{{detail.title}}
			</view>
			<view class="notice-info-wrapper">
				<view class="notice-publisher">
					发布者:小律优创管理员
				</view>
				<view class="notice-date">
					{{detail.created_at}}
				</view>
			</view>
			<view class="notice-content">
				<rich-text :nodes="detail.content" style="width: 100%;"></rich-text>
			</view>
		</view>
	</view>
</template>

<script lang="ts" setup>
	import { onLoad } from '@dcloudio/uni-app';
	import { INotice } from '@/types/notice';
	import REST_URL from '@/http/http.restUrl';
	import { Ref, ref } from 'vue';
	const detail : Ref<INotice | null> = ref(null);

	onLoad(async (e) => {
		// await uni.loginManger.$interceptor;
		if (e && e.id) {
			await getNoticeDetail(e.id);
		}
	})

	const getNoticeDetail = async (aid : number) : Promise<void> => {
		const options = {
			aid,
		}
		const result : INotice = (await uni.http.POST(REST_URL.systemNoticeDetail, options)).data;
		detail.value = result;
	}
</script>

<style scoped lang="scss">
	@import "./noticeDetail.scss";
</style>